<?php
/**
 * Created by PhpStorm.
 * User: wangkxin@foxmail.com
 * Date: 2022/4/11
 * Time: 0:12
 */

use app\index\controller\TestEncrypt;
use think\facade\Route;
use think\middleware\Throttle;
use think\Request;
use think\Response;


Route::get('hello_index','Index/index');

//带路由访问请加模块名 http://tp6demo2.top/index/oss/upview
Route::group('oss',function(){

    //上传界面
    Route::get('upview','Uploadoss/index');

    //上传方法
    Route::post('upimg','Uploadoss/up_image');
});


/**
 * 首页支付测试
 * 首页接口测试接口限流
 */
Route::group('index',function(){
    Route::get('index1','Index/index')->middleware(Throttle::class,['visit_rate'=>'3/m','visit_fail_response'=>function(Throttle $throttle, Request $request, int $wait_seconds){
        return Response::create(['status'=>'400','msg'=>'Too many requests, try again after ' . $wait_seconds . ' seconds.'],'json')->code(429);
        // return json(['msg'=>"每分钟仅能访问3次,请在{$wait_seconds}秒后重试"],'429');
    }]);
    Route::get('testPay','Index/testPay');

    /**
     * ab 压力测试带post,header头 参数
     */
    Route::post('abTest','Index/abTest');

});




/**
 * 并发处理解决超卖问题
 * 并发测试
 */
Route::group('shop',function(){
    Route::get('buy','BuyController/buy');
    Route::get('buy2','BuyController/buy2');
});


/**
 * phpoffice 导出excel 问题
 */
Route::group('phpoffice',function(){
    Route::get('export1','Office/index');
    Route::get('export2','Office/export2');
});



/**
 * 支付测试
 */
Route::group('alipay',function(){

    //测试方法
    Route::get('test','PayController/test');
    //网页支付
    Route::get('webPay','PayController/web');
});

/**
 * 实现的消息实时推送功能 ajax 反推
 */
Route::group('Long',function(){
    //视图
    Route::get('view','LongPolling/index');
    //发送数据
    Route::get('push','LongPolling/ajaxPush');

    //处理输入写入数据库
    Route::get('write','LongPolling/writetxt');
});


/**
 * 测试事件监听
 */
Route::group('Event',function(){
    Route::get('index','TestEvent/index');
    Route::get('info','TestEvent/info');
    Route::get('info1','TestEvent/info1');
});

/**
 * 加解密测试
 */
Route::group('TestEncrypt',function(){
    Route::get('encry','TestEncrypt/testen');
    Route::get('decry','TestEncrypt/testde');
    Route::get('useEncrypt','TestEncrypt/useEncrypt');
});



/**
 * 接口验签
 */









